from PIL import Image, ImageDraw, ImageFont

# 创建画布
img = Image.new('RGB', (600, 300), color='white')
draw = ImageDraw.Draw(img)
font = ImageFont.load_default()

# 绘制概率计算的结果
draw.text((10, 10), "抽到红球的概率: 0.62", fill="black", font=font)
draw.text((10, 50), "抽到蓝球的概率: 0.38", fill="black", font=font)
draw.text((10, 90), "连续两次抽到红球的概率: 0.36", fill="black", font=font)

# 保存图像
img_path = "probability_visualization.png"
img.save(img_path)
print(f"图形已保存为 {img_path}")